import 'package:flutter/foundation.dart';

import '../../../../public.dart';

/// 弹幕控制器
class BarrageController extends ValueNotifier {
  final List<ChapterBarrageModel> _barrageModels = []; // 弹幕实体
  final BarrageSetting _barrageSetting; // 弹幕基础配置

  BarrageController(this._barrageSetting) : super(null);

  BarrageSetting get barrageSetting {
    return _barrageSetting;
  }

  List<ChapterBarrageModel> get barrageModels {
    return _barrageModels;
  }

  saveModel(List<ChapterBarrageModel> list) {
    _barrageModels.addAll(list);
    notifyListeners();
  }
}

/// 弹幕设置
class BarrageSetting {
  double speed; // 速度 '0': '很慢', '25': '慢', '50': '正常', '75': '快', '100': '很快'
  double opacity; // 透明度，满值100
  double safeTopHeight; // 头部安全距离
  double channelPadding; // 通道垂直间距
  double channelHeight; // 通道高度
  int maxChannelCount; // 最大通道数量
  int duration; // 动画持续时间毫秒

  BarrageSetting(
      {this.speed = 50,
      this.opacity = 100,
      this.safeTopHeight = 30,
      this.channelPadding = 10,
      this.channelHeight = 50,
      this.maxChannelCount = 5,
      this.duration = 1000 * 60 * 30});
}

/// 弹幕通道
class BarrageWidgetChannel {
  int channelNum; // 通道号
  int status = 0; // 通道状态
  int durationOffset; // 每个通道动画时间偏移量（用来差异化每个通道移动速度）

  BarrageWidgetChannel(this.channelNum, this.durationOffset);
}
